package com.xian.im.common.utils.sys;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.util.Map;

/**
 * @Auther: xlr
 * @Date: 2018/8/19 14:16
 * @Description:
 */
public class TransferUtil {

    public static <T> T transfer(Object text, Class<T> clazz) {
        return JSONObject.parseObject( JSONObject.toJSONString(text), clazz);
    }

    /**
     * 实体类转 MAP
     * @param obj
     * @return
     */
    public static Map<String,Object> beanToMap(Object obj){
        String json = JSON.toJSONString(obj);
        Map<String,Object> map = JSON.parseObject(json);
        return map;
    }
}
